/*
 * Funciones de ventanas emergentes.
 * Popup window's fuctions
 */
function closeDialog(){
	window.opener.location.reload();
	window.close();	
}

function showConfirmDialog(uri,parameters,message){
	if(confirm(message)){	
		showDialog(uri,parameters);
	}
}

function showDialog(uri,parametros){
		h=400;
		w=600;
		hPos=(screen.width-w)/2;
		vPos=(screen.height-h)/2;		
		var dialog=window.open(uri+"?"+parametros,"dialog",
				"top="+vPos+",left="+hPos+",directories=0,height="+h+
				",location=0,menubar=0,resizable=0,resize=1,status=0,"+
				"toolbar=0,width="+w);
}

function postDialog(target){
	h=400;
	w=600;
	hPos=(screen.width-w)/2;
	vPos=(screen.height-h)/2;		
	var dialog=window.open("",target,
			"top="+vPos+",left="+hPos+",directories=0,height="+h+
			",location=0,menubar=0,scrollbars=1,resizable=0,resize=1,status=0,"+
			"toolbar=0,width="+w);
}

/*
 * Esta función permite mover los elements de una lista a otra
 * This fuction allow to move elements from a list to another
 */
function swapListElements(sourceList,targetList){
	selectedIndexes=new Array();
	for(i=0,j=0;i<sourceList.options.length;i++){
		if(sourceList.options[i].selected){
			option=sourceList.options[i];
			selectedIndexes[j++]=option.index;
		}
	}

	for(i=0,j=targetList.length;i<selectedIndexes.length;i++){
		option=sourceList.options[selectedIndexes[i]];		
		targetList[j++]=new Option(option.text,option.value);
	}

	for(i=sourceList.options.length-1;i>=0;i--){
		if(sourceList.options[i].selected){
			sourceList.options[i]=null;
		}		
	}	
	sourceList.selectedIndex=0;
}
